package NC;

public class NC83 {
    public double maxProduct(double[] arr) {
        if(arr.length==0) return 0;
        double max = arr[0],min = arr[0];
        double res = max;
        for (int i = 1; i < arr.length; i++) {
            double tmax=max,tmin = min;
            max = Math.max(arr[i],arr[i]*tmax);
            max = Math.max(max,arr[i]*tmin);
            min = Math.min(arr[i],arr[i]*tmax);
            min = Math.min(min,arr[i]*tmin);
            res=Math.max(res,max);
        }
        return  res;
    }
}
